{include file="public/head" /}

<style type="text/css">

    .layui-form{
        margin-top: 20px;
    }
    .fieldlist dd ins {
        width: 181px;
        display: inline-block;
        text-decoration: none;
        margin-bottom: 5px;
    }
    .fieldlist dd{
        width: 800px;
    }
    .fieldlist dd input{
        width: 170px;
    }
    .removeclass{
        margin-top: -5px
    }
    dl {
        margin-top: 20px;
    }
    .layui-tab-content .layui-form-label{
        width: 200px
    }
    .layui-tab-content .input-inline{
        width: 600px
    }
</style>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">系统设置</a>
            <a>
              <cite>短信配置</cite></a>
          </span>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-tab">
                <ul class="layui-tab-title">
                    <li class="layui-this">阿里云</li>
                    <li>腾讯云</li>
                    <li>华为云</li>
                    <li>又拍云</li>
                    <li>七牛</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <form action="" method="post" class="layui-form">
                            <input type="text" name="type" value="aliyun" hidden>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用accessKeyId</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="access_key"   placeholder="请输入" required="" lay-verify="required"  autocomplete="off" class="layui-input" value="{$sms_lit.aliyun.access_key?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用accessKeySecret</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="access_secret" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.aliyun.access_secret?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用签名名称</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="sign_name" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.aliyun.sign_name?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">短信模板</label>
                                <div class="layui-input-inline input-inline">
                                            <dl class="fieldlist" data-name="row[template]" data-listidx="0">
                                                <dd>
                                                    <ins>英文名称</ins>
                                                    <ins>中文名称</ins>
                                                    <ins>模板id</ins>
                                                </dd>
                                                {foreach $sms_lit.aliyun.actions as $k=>$v}
                                                <dd class="layui-inline" >
                                                    <div class="layui-inline">
                                                        <input type="text" name="template[yw][]"  class="layui-input" value="{$k?:''}">
                                                    </div>
                                                    <div class="layui-inline">
                                                        <input type="text" name="template[zw][]"  class="layui-input" value="{$v.actions_name?:''}">
                                                    </div>
                                                    <div class="layui-inline">
                                                        <input type="text" name="template[mb][]"  class="layui-input" value="{$v.template_id?:''}">
                                                    </div>
                                                    <button type="button" class="layui-btn layui-btn-sm removeclass"><i class="layui-icon"></i></button>
<!--                                                    <span class="btn btn-sm btn-primary btn-dragsort">-->
<!--                                                        <i class="fa fa-arrows">-->

<!--                                                        </i>-->
<!--                                                    </span>-->
                                                </dd>
                                                {/foreach}
                                            </dl>
                                            <button type="button" class="layui-btn layui-btn-sm layui-btn-add"><i class="layui-icon"></i>追加</button>
                                        <div class="col-sm-4"></div>
                                    </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="repass" class="layui-form-label"></label>
                                <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item">
                        <form action="" method="post" class="layui-form">
                            <input type="text" name="type" value="qcloud" hidden>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用appid</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="appid"   placeholder="请输入" required="" lay-verify="required"  autocomplete="off" class="layui-input" value="{$sms_lit.qcloud.appid?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用appkey</label>
                                <div class="layui-input-inline input-inline" >
                                    <input type="text" name="appkey" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.qcloud.appkey?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用签名</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="sign_name" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.qcloud.sign_name?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">短信模板</label>
                                <div class="layui-input-inline input-inline">
                                    <dl class="fieldlist" data-name="row[template]" data-listidx="0">
                                        <dd>
                                            <ins>英文名称</ins>
                                            <ins>中文名称</ins>
                                            <ins>模板id</ins>
                                        </dd>
                                        {foreach $sms_lit.qcloud.actions as $k=>$v}
                                        <dd class="layui-inline" >
                                            <div class="layui-inline">
                                                <input type="text" name="template[yw][]"  class="layui-input" value="{$k?:''}">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="template[zw][]"  class="layui-input" value="{$v.actions_name?:''}">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="template[mb][]"  class="layui-input" value="{$v.template_id?:''}">
                                            </div>
                                            <button type="button" class="layui-btn layui-btn-sm removeclass"><i class="layui-icon"></i></button>
                                            <!--                                                    <span class="btn btn-sm btn-primary btn-dragsort">-->
                                            <!--                                                        <i class="fa fa-arrows">-->

                                            <!--                                                        </i>-->
                                            <!--                                                    </span>-->
                                        </dd>
                                        {/foreach}
                                    </dl>
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn-add"><i class="layui-icon"></i>追加</button>
                                    <div class="col-sm-4"></div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="repass" class="layui-form-label"></label>
                                <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item">
                        <form action="" method="post" class="layui-form">
                            <input type="text" name="type" value="huawei" hidden>
                            <div class="layui-form-item">
                                <label class="layui-form-label" ><span class="x-red">*</span>APP接入地址</label>
                                <div class="layui-input-inline input-inline" >
                                    <input type="text" name="url"   placeholder="请输入" required="" lay-verify="required"  autocomplete="off" class="layui-input" value="{$sms_lit.huawei.url?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用appKey</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="appkey" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.huawei.appkey?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用appSecret</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="appSecret" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.huawei.appSecret?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>国内短信签名通道号</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="sender" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.huawei.sender?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>签名名称</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="signature" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.huawei.signature?:''}">
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">短信状态报告接收地址</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="statusCallback"  placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.huawei.statusCallback?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">短信模板</label>
                                <div class="layui-input-inline input-inline">
                                    <dl class="fieldlist" data-name="row[template]" data-listidx="0">
                                        <dd>
                                            <ins>英文名称</ins>
                                            <ins>中文名称</ins>
                                            <ins>模板id</ins>
                                        </dd>
                                        {foreach $sms_lit.qcloud.actions as $k=>$v}
                                        <dd class="layui-inline" >
                                            <div class="layui-inline">
                                                <input type="text" name="template[yw][]"  class="layui-input" value="{$k?:''}">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="template[zw][]"  class="layui-input" value="{$v.actions_name?:''}">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="template[mb][]"  class="layui-input" value="{$v.template_id?:''}">
                                            </div>
                                            <button type="button" class="layui-btn layui-btn-sm removeclass"><i class="layui-icon"></i></button>
                                            <!--                                                    <span class="btn btn-sm btn-primary btn-dragsort">-->
                                            <!--                                                        <i class="fa fa-arrows">-->

                                            <!--                                                        </i>-->
                                            <!--                                                    </span>-->
                                        </dd>
                                        {/foreach}
                                    </dl>
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn-add"><i class="layui-icon"></i>追加</button>
                                    <div class="col-sm-4"></div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="repass" class="layui-form-label"></label>
                                <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item">
                        <form action="" method="post" class="layui-form">
                            <input type="text" name="type" value="upyun" hidden>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>请求地址</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="apiurl"   placeholder="请输入" required="" lay-verify="required"  autocomplete="off" class="layui-input" value="{$sms_lit.upyun.apiurl?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>授权token</label>
                                <div class="layui-input-inline input-inline" >
                                    <input type="text" name="token" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.upyun.token?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">短信模板</label>
                                <div class="layui-input-inline input-inline">
                                    <dl class="fieldlist" data-name="row[template]" data-listidx="0">
                                        <dd>
                                            <ins>英文名称</ins>
                                            <ins>中文名称</ins>
                                            <ins>模板id</ins>
                                        </dd>
                                        {foreach $sms_lit.upyun.actions as $k=>$v}
                                        <dd class="layui-inline" >
                                            <div class="layui-inline">
                                                <input type="text" name="template[yw][]"  class="layui-input" value="{$k?:''}">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="template[zw][]"  class="layui-input" value="{$v.actions_name?:''}">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="template[mb][]"  class="layui-input" value="{$v.template_id?:''}">
                                            </div>
                                            <button type="button" class="layui-btn layui-btn-sm removeclass"><i class="layui-icon"></i></button>
                                            <!--                                                    <span class="btn btn-sm btn-primary btn-dragsort">-->
                                            <!--                                                        <i class="fa fa-arrows">-->

                                            <!--                                                        </i>-->
                                            <!--                                                    </span>-->
                                        </dd>
                                        {/foreach}
                                    </dl>
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn-add"><i class="layui-icon"></i>追加</button>
                                    <div class="col-sm-4"></div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="repass" class="layui-form-label"></label>
                                <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item">
                        <form action="" method="post" class="layui-form">
                            <input type="text" name="type" value="qiniu" hidden>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用AccessKey</label>
                                <div class="layui-input-inline input-inline">
                                    <input type="text" name="accessKey"   placeholder="请输入" required="" lay-verify="required"  autocomplete="off" class="layui-input" value="{$sms_lit.qiniu.accessKey?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">*</span>应用appkey</label>
                                <div class="layui-input-inline input-inline" >
                                    <input type="text" name="secretKey" lay-verify="required"  required="" placeholder="请输入" autocomplete="off" class="layui-input" value="{$sms_lit.qiniu.secretKey?:''}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">短信模板</label>
                                <div class="layui-input-inline input-inline">
                                    <dl class="fieldlist" data-name="row[template]" data-listidx="0">
                                        <dd>
                                            <ins>英文名称</ins>
                                            <ins>中文名称</ins>
                                            <ins>模板id</ins>
                                        </dd>
                                        {foreach $sms_lit.qiniu.actions as $k=>$v}
                                        <dd class="layui-inline" >
                                            <div class="layui-inline">
                                                <input type="text" name="template[yw][]"  class="layui-input" value="{$k?:''}">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="template[zw][]"  class="layui-input" value="{$v.actions_name?:''}">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="template[mb][]"  class="layui-input" value="{$v.template_id?:''}">
                                            </div>
                                            <button type="button" class="layui-btn layui-btn-sm removeclass"><i class="layui-icon"></i></button>
                                        </dd>
                                        {/foreach}
                                    </dl>
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn-add"><i class="layui-icon"></i>追加</button>
                                    <div class="col-sm-4"></div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="repass" class="layui-form-label"></label>
                                <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/static/lib/layui/lay/modules/form.js"></script>
<script type="text/javascript" >

    $(".layui-tab-title li").click(function(){
        var picTabNum = $(this).index();
        sessionStorage.setItem("picTabNum",picTabNum);
    });
    $(function(){
        var getPicTabNum = sessionStorage.getItem("picTabNum");
        $(".layui-tab-title li").eq(getPicTabNum).addClass("layui-this").siblings().removeClass("layui-this");
        $(".layui-tab-content>div").eq(getPicTabNum).addClass("layui-show").siblings().removeClass("layui-show");
    })

    //动态添加input输入框
    $("body").on('click', ".layui-btn-add", function () {
        var t = $(this).siblings('.fieldlist');
        var str = '<dd class="layui-inline">' +
            '<div class="layui-inline">' +
            '<input type="text" name="template[yw][]" class="layui-input">' +
            '</div>' +
            '<div class="layui-inline" style="margin-left: 4px">' +
            '<input type="text" name="template[zw][]" class="layui-input">' +
            '</div>' +
            '<div class="layui-inline" style="margin-left: 4px">' +
            '<input type="text" name="template[mb][]" class="layui-input">' +
            '</div>' +
            '<button type="button" class="layui-btn layui-btn-sm removeclass" style="margin-left: 4px"><i class="layui-icon"></i></button>' +
            '</dd>';

        t.append(str);
    });

    //删除动态添加的input输入框
    $("body").on('click', ".removeclass", function () {
        var parentEle = $(this).parent();
        parentEle.remove();
    });

    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data){
            //发异步，把数据提交给php
            $.ajax({
                type: "POST",
                url: "{:getUrl()}Sms/index",
                data: data.field,
                dataType: "json",
                success: function(data){
                    if(data.code == 200)
                    {
                        layer.msg(data.msg, {icon: 6},function(){
                            // 可以对父窗口进行刷新
                            window.parent.location.reload();
                            return false;
                        });
                    }
                    else
                    {
                        layer.msg(data.msg,{icon: 5,time:1000});
                    }
                }
            });
            // layer.alert("增加成功", {icon: 6},function () {
            //     // 获得frame索引
            //     var index = parent.layer.getFrameIndex(window.name);
            //     //关闭当前frame
            //     parent.layer.close(index);
            // });
            return false;
        });



    });
</script>
</html>
